package com.yuandian.middle.platform.contoller;

import com.yuandian.api.middle_platform.po.OrgAbilityParam;
import com.yuandian.bpm.common.core.util.R;
import com.yuandian.middle.platform.service.IOrgAbilityOverviewService;
import com.yuandian.utils.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 说明：能力服务分析controller
 * @Author tianlr
 * @Date 2023/5/18 14:11
 */
@Api(value = "abilityServerAnalysis", tags = "能力服务分析接口")
@RestController
@RequestMapping("/modules/abilityServerAnalysis")
public class AbilityServerAnalysisController {
    @Autowired
    private IOrgAbilityOverviewService orgAbilityOverviewService;

    /**
     * 查询服务对应的使用方数
     * @return
     */
    @PostMapping("/queryDataByAbilityServer")
    @ApiOperation(value = "查询能力对应的使用方数", notes = "查询能力对应的使用方数，必填参数：abilityCode、serviceCode")
    public R queryDataByAbilityServer(@RequestBody OrgAbilityParam param) {
        if (param == null || StringUtils.isEmpty(param.getAbilityCode()) || StringUtils.isEmpty(param.getServiceCode())) {
            return R.failed("传入参数不正确！abilityCode、serviceCode不能为空");
        }
        return orgAbilityOverviewService.selectDataByAbility(param, 0);
    }
}
